package com.mouse.controller.user;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mouse.common.lang.Result;
import com.mouse.entity.*;
import com.mouse.entity.vo.DoubleAlleleVO;
import com.mouse.entity.vo.GeneAlleleVO;
import com.mouse.mapper.*;
import com.mouse.service.DoubleAllelesService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author godson
 * @since 2022-08-07
 */
@RestController
@RequestMapping("/double-alleles")
public class DoubleAllelesController {

    @Autowired
    GeneCategoryMapper geneCategoryMapper;

    @Autowired
    private DiseaseMapper diseaseMapper;

    @Autowired
    private GeneAlleleMapper geneAlleleMapper;

    @Autowired
    private GeneCompositionMapper geneCompositionMapper;

    @Autowired
    private PhenotypeMapper phenotypeMapper;

    @Autowired
    private ReferenceMapper referenceMapper;

    @Autowired
    DoubleAllelesService doubleAllelesService;
    @GetMapping("/get/")
    public Result select(@Validated @RequestParam String key, @RequestParam String value, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int pageSize ){
        IPage<DoubleAlleles> page = new Page<>(pageNum,pageSize);
        IPage<DoubleAlleles> info = doubleAllelesService.getInfoByMap(page, key, value);
        if(info.getSize()==0){
            return Result.fail("无对应记录");
        }
        return Result.succ(info);
    }

    @GetMapping("/info/{did}")
    public Result getInfo(@PathVariable(name="did") Long did){
        DoubleAlleles doubleAlleles = doubleAllelesService.getById(did);
        DoubleAlleleVO doubleAlleleVO = doubleAllelesService.getDoubleAlleleVO(doubleAlleles);
        return Result.succ(doubleAlleleVO);

    }

//    @GetMapping("/gene-composition/{did}/{currentPage}/{pageSize}")
//    public Result getGeneCompositionByDid(@PathVariable(name="did") Long did,
//                                          @PathVariable Integer currentPage,
//                                          @PathVariable Integer pageSize){
//        Page<GeneComposition> page = new Page<>(currentPage,pageSize);
//        Page<GeneComposition> pages = geneCompositionMapper.getGeneCompositionByDid(page, did);
//        return Result.succ(pages);
//    }
//
//
//    @GetMapping("/reference/{did}/{currentPage}/{pageSize}")
//    public Result getReferenceByDid(@PathVariable(name="did") Long did,
//                                    @PathVariable Integer currentPage,
//                                    @PathVariable Integer pageSize){
//        Page<Reference> page = new Page<>(currentPage,pageSize);
//        Page<Reference> pages = referenceMapper.getReferenceByDid(page, did);
//        return Result.succ(pages);
//    }
//
//    @GetMapping("/phenotype/{did}/{currentPage}/{pageSize}")
//    public Result getPhenotypeByDid(@PathVariable(name="did") Long did,
//                                    @PathVariable Integer currentPage,
//                                    @PathVariable Integer pageSize){
//        Page<Phenotype> page = new Page<>(currentPage,pageSize);
//        Page<Phenotype> pages = phenotypeMapper.getPhenotypeByDid(page, did);
//        return Result.succ(pages);
//    }
//
//    @GetMapping("/gene-allele/{did}/{currentPage}/{pageSize}")
//    public Result getGeneAlleleByDid(@PathVariable(name="did") Long did,
//                                     @PathVariable Integer currentPage,
//                                     @PathVariable Integer pageSize){
//        Page<GeneAllele> page = new Page<>(currentPage,pageSize);
//        Page<GeneAllele> pages = geneAlleleMapper.getGeneAllelesByDid(page, did);
//        return Result.succ(pages);
//    }
//
//    @GetMapping("/disease/{did}/{currentPage}/{pageSize}")
//    public Result getDiseaseByDid(@PathVariable(name="did") Long did,
//                                  @PathVariable Integer currentPage,
//                                  @PathVariable Integer pageSize){
//        Page<Disease> page = new Page<>(currentPage,pageSize);
//        Page<Disease> pages = diseaseMapper.getDiseaseByDid(page, did);
//        return Result.succ(pages);
//    }




}
